package leetcode.code1566;

import leetcode.helper.HelpDebug;

public class Solution {
	public boolean containsPattern(int[] arr, int m, int k) {
		int len = arr.length;
		for (int l = 0; l <= len - m * k; l++) {
			int r = l + m;
			boolean ok = true;
			go: for (int i = 0; i < k - 1; i++) {
				for (int j = 0; j < m; j++) {
					if (arr[l + j] != arr[r + i * m + j]) {
						ok = false;
						break go;
					}
				}
			}
			if (ok) {
				return true;
			}
		}
		return false;
	}

	public static void main(String[] args) {
		Solution so = new Solution();
		boolean a = so.containsPattern(HelpDebug.str2array3("[1,2,1,2,1,1,1,3]"), 2, 2);
		System.out.println(a);
		boolean b = so.containsPattern(HelpDebug.str2array3("[1,2,4,4,4,4]"), 1, 3);
		System.out.println(b);
		HelpDebug.compare(false, so.containsPattern(HelpDebug.str2array3("[1,2,3,1,2]"), 2, 2));
		HelpDebug.compare(false, so.containsPattern(HelpDebug.str2array3("[2,2,2,2]"), 2, 3));
	}
}
